Windows10에서 FastAPI 설치 시 보안 오류
✒️ 2026-03-01 13:14 내용 수정
📋 문제 개요
문제 설명
python 가상환경을 구성하고 실행하는 명령어를 입력했을 때 보안 문제가 발생하여 가상환경이 실행되지 않음.
🔍 상세 정보
발생 환경
- 환경: 개발 환경 설정
- 서버/인스턴스: 없음
- 브라우저/디바이스: Windows 10
- 관련 버전: Python 3.12.10
재현 방법
- FastAPI 공식 문서와 블로그 가이드글을 따라 Windows 10 환경에서 VSC 터미널/PowerShell로 python 가상 환경 설치 및 실행
# 디렉터리 생성
mkdir workspace
# 디렉터리로 이동
cd workspace
# venv 모듈로 가상환경 생성
python -m venv .venv
# 가상환경 실행
.\\activate
에러 메시지 및 로그
.\\activate : 이 시스템에서 스크립트를 실행할 수 없으므로 \\workspace\\Scrip
ts\\Activate.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execut
ion_Policies(<https://go.microsoft.com/fwlink/?LinkID=135170>)를 참조하
십시오.
위치 줄:1 문자:1
+ .\\activate
+ ~~~~~~~~~~
+ CategoryInfo : 보안 오류: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
🔎 원인 분석
조사 과정
- 인터넷에 “python 가상 환경 중 보안 문제 발생”이라는 주제로 검색을 진행하여 비슷한 사례를 찾음.
- [Python-개발환경]Python파이썬 가상 환경(.venv) 보안 오류 :: 콩이의 일상과 임베디드 Blog
근본 원인
PowerShell에서 악성 스크립트 실행을 방지하기 위한 보안 정책으로 인해 Python 가상 환경 실행 스크립트를 실행할 수 없는 것이 원인.
PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.5
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.5
✅ 해결 방법
적용한 솔루션
- Windows PowerShell을 관리자 권한으로 실행한 후
Set-ExecutionPolicy Unrestricted를 입력하고,y로 허용한 뒤엔 정상적으로 가상 환경이 활성화되었음.